package lt.kraujutis.vilius.android.listallavailablesensors;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class SensorDetailsActivity extends ListActivity {
	/**
	 * @see android.app.Activity#onCreate(Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		int sensorType = getIntent().getIntExtra("sensorType", Sensor.TYPE_ALL);
		SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
		List<Sensor> sensorList = mSensorManager.getSensorList(sensorType);

		List<String> sensorsDetails = new ArrayList<String>();
		for (Sensor sensor : sensorList) {
			sensorsDetails.add(getString(R.string.string_name_) + sensor.getName());
			sensorsDetails.add(getString(R.string.int_type_) + sensor.getType());
			sensorsDetails.add(getString(R.string.float_maximumrange_)
					+ sensor.getMaximumRange());
			sensorsDetails.add(getString(R.string.float_power_) + sensor.getPower());
			sensorsDetails.add(getString(R.string.float_resolution_) + sensor.getResolution());
			sensorsDetails.add(getString(R.string.string_vendor_) + sensor.getVendor());
			sensorsDetails.add(getString(R.string.int_version_) + sensor.getVersion());
		}

		setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
				sensorsDetails));
	}
}
